var net = require('net');

//net.Socket
var sock = net.connect({
    port:6080,
    host:'127.0.0.1',
}, function () {
    console.log('connected to server');        
});

sock.on("connect",function () {
    console.log("connect success");
    
    sock.write("HelloWorld");
});

sock.on("error",function (err) {
    console.log("error");
});

sock.on("close",function () {
    console.log("close");
});

sock.on("end",function() {
    console.log("end event");   
});

// 当有数据发生的时候，调用;
sock.on("data", function(data) {
	console.log("server send data ",data);
});